﻿using System;

namespace Coding4Fun.Cannon.Phone.Cannon
{
    public static class CannonDrive
    {
        const int FastWheel = 80;
        const int SlowWheel = -20;
        const int DefaultWheel = 40; 

        public static void SetEngineSpeed(out int leftEngine, out int rightEngine, DrivingMode drive, double yAxis)
        {
            leftEngine = DefaultWheel;
            rightEngine = DefaultWheel; 

            var turn = CannonUtility.GetTurn(yAxis);

            switch (turn)
            {
                case TurningAction.Left:
                    leftEngine = SlowWheel; 
                    rightEngine = FastWheel;

                    break;
                case TurningAction.Right:
                    rightEngine = SlowWheel;
                    leftEngine = FastWheel; 
                    break;
                case TurningAction.None:
                    break;
                default:
                    break;
            }

            switch (drive)
            {
                case DrivingMode.Forward:
                    break;
                case DrivingMode.Reverse:
                    leftEngine *= -1;
                    rightEngine *= -1; 
                    break;
                default:
                    break;
            }

            Logger.WriteLine(String.Format("Set Engine Speed: Left:{0}, Right:{1}", leftEngine, rightEngine)); 
        }
    }
}
